package com.jiangyg.mall.order.service;

import com.jiangyg.mall.core.support.restful.Pagination;
import com.jiangyg.mall.db.mybatis.BaseServiceImpl;
import com.jiangyg.mall.order.dao.RefundInfoDao;
import com.jiangyg.mall.order.dto.RefundInfoDTO;
import com.jiangyg.mall.order.entity.RefundInfo;
import com.jiangyg.mall.order.vo.RefundInfoVO;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class RefundInfoServiceImpl extends BaseServiceImpl<RefundInfoDao, RefundInfo> implements RefundInfoService {

    @Autowired
    public RefundInfoServiceImpl(RefundInfoDao refundInfoDao) {
        super(refundInfoDao);
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public Pagination<RefundInfoVO> selectPagination(Pagination<RefundInfoVO> pagination) throws Exception {
        return this.executeSelectPagination(pagination, RefundInfoVO.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean saveOrUpdate(RefundInfoDTO dto) throws Exception {
        return this.executeSaveOrUpdate(dto) > 0;
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public RefundInfoVO selectById(Long refundInfoId) throws Exception {
        return this.executeSelectById(refundInfoId, RefundInfoVO.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean delete(List<Long> refundInfoIds) {
        return this.baseMapper.deleteBatchIds(refundInfoIds) > 0;
    }

}
